package work3.work1;

import Uti.ScannerUti;

public class Goods {
    private String name; //名称
    private int num  ;//数量
    private double price  ;//单价
    private double totalPrice ; //总价

    public Goods(String name, int num) {
        this.name = name;
        this.num = num;
    }

    public Goods() {
    }

    public void seal(int nums){
        this.num-=nums;
    }
    public void add(int num){this.num+=num;}
    public Goods(String name, int num, double price, double totalPrice) {
        this.name = name;
        this.num = num;
        this.price = price;
        this.totalPrice = totalPrice;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return num
     */
    public int getNum() {
        return num;
    }

    /**
     * 设置
     * @param num
     */
    public void setNum(int num) {
        this.num = num;
    }

    /**
     * 获取
     * @return price
     */
    public double getPrice() {
        return price;
    }

    /**
     * 设置
     * @param price
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     * 获取
     * @return totalPrice
     */
    public double getTotalPrice() {
        return totalPrice;
    }


    public void setTotalPrice() {
        this.totalPrice = num*price;
    }

    public String toString() {
        return String.format("%-10s;单价：%-10s;购买数量：%-10s;总计：%-10s",
                name,price,num,totalPrice);
    }
}
